package com.tchy.cloud.controller;

import com.tchy.cloud.entity.ACustomerCapitalEntity;
import org.apache.log4j.Logger;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.common.service.CommonService;
import org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.tag.vo.datatable.SortDirection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by xiaoji on 2017/2/23.
 * 交易记录
 */
@Controller
@RequestMapping("/capitalController")
public class CapitalController {
    private static final Logger logger = Logger.getLogger(CapitalController.class.getName());
    @Autowired
    private CommonService commonService;


    /**
     * 交易记录
     *
     * @return
     */
    @RequestMapping(params = "view")
    public ModelAndView record(Long customerId,HttpServletRequest request) {
        request.setAttribute("customerId",customerId);
        return new ModelAndView("clound/capital/view");
    }

    /**
     * 获取咨询师列表
     * @param aCustomerCapitalEntity 交易记录对象
     * @param request
     * @param response
     * @param dataGrid
     */
    @RequestMapping(params = "datagrid")
    public void datagrid(ACustomerCapitalEntity aCustomerCapitalEntity, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
        CriteriaQuery cq = new CriteriaQuery(ACustomerCapitalEntity.class, dataGrid);
        cq.addOrder("capitalId", SortDirection.desc);
        cq.add();
        // 查询条件组装
        HqlGenerateUtil.installHql(cq, aCustomerCapitalEntity, request.getParameterMap());
        commonService.getDataGridReturn(cq, true);
        TagUtil.datagrid(response, dataGrid);
    }
}
